import axios from 'axios'

export const JobDetailsService = class JobDetailsService {
    static jobDetailsService = null
    requestUrl = '/purchase/jobDetails'

    static getInstance() {
        if (this.jobDetailsService == null) {
            this.jobDetailsService = new JobDetailsService()
        }
        return this.jobDetailsService
    }

    /**
     * 分页查询
     * @param params
     */
    pageQuery(params) {
        return axios.get(`${this.requestUrl}/page`, {
            params
        })
    }

    /**
     * 新增任务
     * @param data
     */
    save(data) {
        return axios.post(this.requestUrl, data)
    }

    /**
     * 修改任务
     * @param data
     */
    update(data) {
        return axios.put(this.requestUrl, data)
    }

    /**
     * 暂停任务
     * @param data
     */
    pause(data) {
        return axios.post(`${this.requestUrl}/pause`, data)
    }

    /**
     * 继续任务
     * @param data
     */
    resume(data) {
        return axios.post(`${this.requestUrl}/resume`, data)
    }

    /**
     * 删除任务
     * @param data
     */
    delete(data) {
        return axios.post(`${this.requestUrl}/delete`, data)
    }

    /**
     * 根据任务名查询
     * @param jobName
     */
    info(jobName) {
        return axios.get(`${this.requestUrl}/info`,{
            params:{
                jobName
            }
        })
    }
}
